{extend name="layout/main" /}

{block name="header"}

{/block}

{block name="content"}
<section class="panel">
    <header class="panel-heading">
        <h4>订单列表-{if $Request.get.types == '1'} 待发货 {/if}{if $Request.get.types == '2'} 待收货 {/if}{if $Request.get.types == '3'} 已完成 {/if}{if $Request.get.types == '0'} 待付款 {/if}</h4>
    </header>
    <div class="panel-body" style="padding-bottom: 50px">
        <form class="form-horizontal" action="{:url('goodsorders/index')}">
            <div class="form-group">

                <div class="col-xs-2 no-pd-r">
                    <select name="type" id="type" class="form-control">
                        <option {if $Request.get.type == 'nick_name'} selected {/if}   value="mobile">买家账号</option>
                        <option {if $Request.get.type == 'number'} selected {/if}   value="number">订单编号</option>
                    </select>
                </div>
                <div class="col-xs-3">
                    <input type="text" value="" name="search" id="search" class="form-control"
                           placeholder="请输入搜索内容">
                </div>
               <!-- <div class="col-xs-1 no-pd-r">
                    <select name="types" id="types" class="form-control">
                        <option value="-1">全部类型</option>
                        <option {if $Request.get.types == '1'} selected {/if} value="1">待发货</option>
                        <option {if $Request.get.types == '2'} selected {/if} value="2">待收货</option>
                        <option {if $Request.get.types == '3'} selected {/if} value="3">已完成</option>
                        <option {if $Request.get.types == '9'} selected {/if} value="0">待付款</option>
                    </select>
                </div>-->
                <button type="submit" class="btn btn-color">搜索</button>
                <a type="button" onclick="xlsx()" class="btn btn-info">导出</a>
            </div>
        </form>
        <table class="table table-bordered table-striped no-margin">
            <thead>
            <tr>
                <th class="text-center">ID</th>
                <th class="text-center">订单号</th>
                <th class="text-center">买家账号</th>
                <th class="text-center">商品名称</th>
                <th class="text-center">商品规格</th>
                <th class="text-center">数量</th>
                <th class="text-center">付款金额</th>
                <th class="text-center">收件人</th>
                <th class="text-center">联系手机号</th>
                <th class="text-center">地址</th>
                <th class="text-center">快递单号</th>
                <th class="text-center">订单时间</th>
                <th class="text-center">状态</th>
                <th class="text-center">操作</th>
            </tr>
            </thead>
            <tbody>
            {if !empty($lists)}
            {foreach $lists as $key=> $entity}
            <tr>
                <td class="text-center">{$key+1}</td>

                <td class="text-center">{$entity->order_number}</td>
                <td class="text-center">{$entity->user_nick_name}</td>
                <td class="text-center">
                    <img src="{$entity->img}" style="width:50px;height:50px; ">
                    {$entity->goods_title}
                </td>
                <td class="text-center">{$entity->pp}</td>
                <td class="text-center">{$entity->pay_num}</td>
                <td class="text-center">{$entity->pay_money}</td>
                <td class="text-center">{$entity->user_name}</td>
                <td class="text-center">{$entity->mobile}</td>
                <td class="text-center">{$entity->address}</td>
                <td class="text-center">
                    {$entity->expressnumber}
                    <br/>
                    {volist name="cate" id="c"}
                        {if $entity->express == $c.key}{$c.name}{/if}
                    {/volist}
                </td>
                <td class="text-center">下单:{if !$entity->pay_time}{$entity->create_time}{else}<?php echo date("Y-m-d H:i:s",$entity->pay_time);?>{/if}
                    <br>{if $entity->send_time}发货时间：{:date('Y-m-d H:i:s',$entity->send_time)}{/if}
                    <br>{if $entity->finish_time}完成时间：{:date('Y-m-d H:i:s',$entity->finish_time)}{/if}
                </td>

                <td class="text-center">{$entity->getStatusName($entity->status)} </td>

                <td class="text-center">
                    {if $entity->status == 1 /}
                    <a href="{:url('goodsorders/edit',['order_number'=>$entity->order_number])}" class="btn btn-xs btn-info">确认发货</a>
                    {elseif $entity->status == 2 /}
                    <a data-url="{:url('goodsorders/cancel',['order_number'=>$entity->order_number])}" onclick="main.ajaxDelete(this)"
                       data-msg="确定要取消发货吗？" class="btn btn-xs btn-danger">取消发货</a>
                    {/if}
                </td>
            </tr>
            {/foreach}
            {else /}
            <tr class="text-center">
                <td colspan="5">暂无数据</td>
            </tr>
            {/if}
            </tbody>
        </table>
        <div class="page">
            {:htmlspecialchars_decode($lists->render())}
        </div>
    </div>
</section>
{/block}


{block name="footer"}
<script>
    function showContent(e){
        $.dialog({
            title: '商品信息',
            content: $(e).attr('data-content')
        });
    }
    function xlsx(){
        var str = '?type='+$('#type option:selected').val();
        if($('#search').val() != ''){
            str+='&search='+$('#search').val()
        }
        if($('#types option:selected').val() != -1){
            str+='&types='+$('#types').val()
        }
        console.log("{:url('admin/Excelexport/orderList')}"+str);
        window.location.href = "{:url('admin/Excelexport/orderList')}"+str;
    }
</script>
{/block}